#ifndef __DS1302_H_
#define __DS1302_H_

#include "sys.h"

#define DS1302_DEBUG 0

#define SEC_REG (0x40 << 1)
#define MIN_REG (0x41 << 1)
#define HOUR_REG (0x42 << 1)
#define MDAY_REG (0x43 << 1)
#define MONTH_REG (0x44 << 1)
#define WDAY_REG (0x45 << 1)
#define YEAR_REG (0x46 << 1)
#define PROTECT_REG (0x47 << 1)
#define CHARGER_REG (0x48 << 1)

typedef enum
{
    YEAR,  /* !> time type year */
    MONTH, /* !> time type month */
    MDAY,  /* !> time type mday */
    HOUR,  /* !> time type hour */
    MIN,   /* !> time type min */
    SEC,   /* !> time type sec */
    WDAY   /* !> time type wday */
} ds1302_enum;

typedef struct
{
    uint8_t year;  /* !> time year */
    uint8_t month; /* !> time month */
    uint8_t mday;  /* !> time mday */
    uint8_t hour;  /* !> time hour */
    uint8_t min;   /* !> time min */
    uint8_t sec;   /* !> time sec */
    uint8_t wday;  /* !> time wday */
} ds1302_data_t;

void ds1302_set_time(uint8_t year, uint8_t month, uint8_t mday, uint8_t hour, uint8_t min, uint8_t sec, uint8_t wday);
uint8_t ds1302_get_time(ds1302_enum data_t);
void ds1302_proc(void);

#endif
